package com.googlecode.dgwt.client.dojox.data;

import java.util.Collection;

import com.googlecode.dgwt.client.dojo.data.model.StoreModel;
import com.googlecode.dgwt.client.dojo.reflect.DojoBean;
import com.googlecode.dgwt.client.dojox.data.base.DataStoreBase;
import com.googlecode.dgwt.client.dojox.data.model.BeanColumn;
import com.googlecode.dgwt.client.dojox.data.model.BeanModel;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class BeanStore<Item> extends DataStoreBase<Item,BeanModel<Item>,BeanColumn<Item>> {

    public BeanStore(Class<? extends DojoBean> classType) {
        super(new BeanModel<Item>(classType));
    }

    public BeanStore(Class<? extends DojoBean> classType, Collection<? extends Item> items) {
        super(new BeanModel<Item>(classType), items);
    }

    public BeanStore(Class<? extends DojoBean> classType, int initialCapacity) {
        super(new BeanModel<Item>(classType), initialCapacity);
    }

    protected BeanStore(BeanStore<Item> mirroredStore, BeanModel<Item> newModel) {
        super(mirroredStore, newModel);
    }

    @Override
    @SuppressWarnings("unchecked")
    public BeanStore<Item> createMirror(StoreModel<Item, ?> model) {
        return new BeanStore<Item>(this, (BeanModel<Item>) model);
    }

    @Override
    public BeanStore<Item> createMirror() {
        return createMirror(getModel());
    }

    @Override
    protected Class<?> getModelBaseClass() {
        return BeanModel.class;
    }

}
